package com.hp.docker_base.controller;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class CurlSimulation {
    public static void main(String[] args) {
        try {
            String url = "https://justmysocks6.net/members/getbwcounter.php?service=338680&id=3ba2307d-6ef8-4301-880e-b20f5db4ab88";

            // 创建URL对象
            URL requestUrl = new URL(url);

            // 打开连接
            HttpURLConnection connection = (HttpURLConnection) requestUrl.openConnection();

            // 设置请求方法
            connection.setRequestMethod("GET");

            // 获取响应状态码
            int responseCode = connection.getResponseCode();

            // 读取响应内容
            BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String line;
            StringBuilder response = new StringBuilder();
            while ((line = reader.readLine()) != null) {
                response.append(line);
            }
            reader.close();

            // 输出响应内容
            System.out.println("Response Code: " + responseCode);
            System.out.println("Response Body: " + response.toString());

            // 关闭连接
            connection.disconnect();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}